package com.bawei.yangzongcai___day2.MVCAcyivity;

import android.widget.ImageView;

import com.bawei.yangzongcai___day2.R;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * create by ertu
 * create on 2021/7/27
 * description
 */
public class BaseMullseeAdpter extends BaseMultiItemQuickAdapter<JavaMVC.DataBean , BaseViewHolder> {

    public BaseMullseeAdpter(@Nullable List<JavaMVC.DataBean> data) {
        super(data);
        addItemType(1, R.layout.creputadpter3);
        addItemType(2, R.layout.creputadpter1);
        addItemType(3, R.layout.creputadpter2);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, JavaMVC.DataBean dataBean) {
        switch (dataBean.getItemType())
        {
            case 2:
                baseViewHolder.setText(R.id.creput1_text1,dataBean.getDesc());
                Glide.with(getContext()).load(dataBean.getUrl()).into((ImageView) baseViewHolder.getView(R.id.creput1_img1));
                break;

            case 3:
                Glide.with(getContext()).load(dataBean.getUrl()).into((ImageView) baseViewHolder.getView(R.id.creput2_img1));
                Glide.with(getContext()).load(dataBean.getUrl()).into((ImageView) baseViewHolder.getView(R.id.creput2_img2));
                break;


            case 1:
                Glide.with(getContext()).load(dataBean.getUrl()).into((ImageView) baseViewHolder.getView(R.id.creput3_img));
                baseViewHolder.setText(R.id.creput3_text1,dataBean.getTitle());
                baseViewHolder.setText(R.id.creput3_text2,dataBean.getCreatedAt());
                baseViewHolder.setText(R.id.creput3_text3,dataBean.getDesc());
                break;

        }
    }


}
